//
// Created by 高森森 on 2022/9/20.
//

#ifndef LEETCODE_SOLUTION_2_H
#define LEETCODE_SOLUTION_2_H
#include<bits/stdc++.h>
using namespace std;

class solution_2 {
public:
    int findPoisonedDuration(vector<int>& timeSeries, int duration) {
        int last=0;
        int ans=0;
        for(int i=0;i<timeSeries.size();i++){
            if(last<timeSeries[i]){
                last=timeSeries[i]+duration-1;
                ans+=duration;
            }else{
                ans+=timeSeries[i]+duration-1-last;
                last=timeSeries[i]+duration-1;
            }
        }
        return ans;
    }
};


#endif //LEETCODE_SOLUTION_2_H
